package br.com.j7.jdesk.persistence.entity;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Version;

import br.com.j7.jdesk.persistence.listener.PreferenceListener;

/**
 * 
 * @author Edivando Alves
 *
 */
@Entity
@EntityListeners(value={PreferenceListener.class})
public class Preferences implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Integer idPreference;
	private String cdPreference;
	private String vlPreference;
	private Integer idUser;
	@Version
	private Integer nrVersion;

	public Preferences() {
	}

	public Integer getIdPreference() {
		return idPreference;
	}

	public void setIdPreference(Integer idPreference) {
		this.idPreference = idPreference;
	}

	public String getCdPreference() {
		return cdPreference;
	}

	public void setCdPreference(String cdPreference) {
		this.cdPreference = cdPreference;
	}

	public String getVlPreference() {
		return vlPreference;
	}

	public void setVlPreference(String vlPreference) {
		this.vlPreference = vlPreference;
	}

	public Integer getIdUser() {
		return idUser;
	}

	public void setIdUser(Integer idUser) {
		this.idUser = idUser;
	}

	public Integer getNrVersion() {
		return nrVersion;
	}
	
	public void setNrVersion(Integer nrVersion) {
		this.nrVersion = nrVersion;
	}
	
	@Override
	public int hashCode() {
		return idPreference;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Preferences other = (Preferences) obj;
		if (idPreference == null) {
			if (other.idPreference != null)
				return false;
		} else if (!idPreference.equals(other.idPreference))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return this.cdPreference+"  "+vlPreference;
	}
}
